<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <title>行业资讯</title>
    <link rel="stylesheet" href="../../css/api.css">
    <link rel="stylesheet" href="../../css/vant.css">
    <link rel="stylesheet" href="../../css/main.css">
    <style>
        .van-tabs__line {
            width: .3rem !important;
        }

        .repair-f3 div {
            background: #E6E6E6 100%;
            border: .01rem solid #E6E6E6 !important;
            color: #999 !important;
        }

        html,
        body {
            background-color: #FFFFFF;
        }
    </style>
</head>

<body>
    <div class="app" v-cloak>
        <div v-if="listNews&&listNews.length>0">
            <!-- 资讯 -->
            <div class="news">
                <div class="news-item" v-for="(item,index) in listNews" :key="index" @click="goDetail(item)">
                    <div class="left">
                        <div class="new-title">{{item.title}}</div>
                        <div class="time">{{handleTimeYMD2(item.createTime)}}</div>
                    </div>
                    <div class="right" v-if="item.coverPicture">
                        <img v-lazy="item.coverPicture?item.coverPicture:'https://zzzzkj.oss-cn-shanghai.aliyuncs.com/static/tiexie/app/image/image/default/loading3.png'" alt=""
                            width="100" height="80" style="border-radius: 0.04rem;">
                    </div>
                </div>
            </div>
            <div class="no-more" v-if="!hasNext">没有更多了</div>
        </div>
        <div v-else class="collect-empty">
            <img src="https://zzzzkj.oss-cn-shanghai.aliyuncs.com/static/tiexie/app/image/image/empty/empty.png" alt="">
            <div>暂无内容～</div>
        </div>

    </div>
    <script src="../../script/api.js"></script>
    <script src="../../script/flexible.js"></script>
    <script src="../../script/fastclick.js"></script>
    <script src="../../script/vue.min.js"></script>
    <script src="../../script/iconfont.js"></script>
    <script src="../../script/vant.min.js"></script>
    <script src="../../script/common.js"></script>
    <script src="../../script/businessCommon.js"></script>
    <script src="../../script/restful.js"></script>
    <script src="../../script/vue-lazyload.js"></script>
    <script>
        apiready = function () {
            imgLazyLoad();
            vm = new Vue({
                el: '.app',
                data: {
                    objectParam: {
                        pageNum: 1,
                        pageSize: 10,
                        channerId: null
                    },
                    hasNext: true,
                    listNews: [],
                },
                mounted() {
                    this.objectParam.channelId = api.pageParam.channelId || null
                    // 获取数据
                   this.getData()
                },
                methods: {
                    getData() {
                        let vm = this
                        index.news("getListNews")(vm.objectParam, (ret) => {
                            vm.listNews = ret.data
                            if (vm.objectParam.pageNum == 1) {
                                vm.listNews = ret.data.list
                            } else {
                                vm.listNews = vm.listNews.concat(ret.data.list)
                            }
                            vm.hasNext = ret.data.hasNext
                        })
                    },
                    back() {
                        api.closeWin();
                    },
                    // 跳转到详情页
                    goDetail(item) {
                        api.openWin({
                            name: 'industry_news_detail_win',
                            url: 'industry_news_detail_win.html',
                            bounces: false,
                            pageParam: {
                                id: item.id,
                            }
                        });
                    }
                },
            })

            // 下拉刷新
            api.setRefreshHeaderInfo({
                bgColor: '#f7f7f7',
                textDown: '下拉更新有惊喜',
                textUp: '松开可以刷新'
            }, function (ret, err) {
                vm.listNews = []
                vm.objectParam.pageNum = 1
                vm.getData();
            });
            // 上拉加载
            api.addEventListener({
                name: 'scrolltobottom',
                extra: {
                    threshold: -10
                }
            }, function (ret, err) {
                console.log('加载');
                if (vm.hasNext) {
                    vm.objectParam.pageNum++
                    vm.getData();
                }
            });

        }
    </script>
</body>

</html>